package com.hornsun.data.dbo;

import com.hornsun.util.ObjByteUtil;

import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.InputStream;

/**
 * Created by zhouzhenyan on 2018/5/30.
 */
public class LoginData {
    public byte[] name = new byte[16];
    public byte[] encyptPwd = new byte[16];
    public byte[] mac = new byte[8];
    public int token;

    public static LoginData fromBytesArray(byte[] array) {
        try {
            InputStream stream = new ByteArrayInputStream(array);
            DataInputStream inputStream = new DataInputStream(stream);
            LoginData loginData = new LoginData();
            inputStream.read(loginData.name, 0, 16);
            inputStream.read(loginData.encyptPwd, 0, 16);
            inputStream.read(loginData.mac, 0, 8);
            loginData.token = ObjByteUtil.BytesOrderConv(inputStream.readInt());
            return loginData;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
